<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@include file="/common/taglibs.jsp"%>

<!DOCTYPE html>
<html class='no-js' lang='cn'>
  <jsp:include page="/head.jsp"/>
  <link rel="stylesheet" href="${ctx }/editor/lib/codemirror.css">
  <link rel="stylesheet" href="${ctx }/editor/addon/dialog/dialog.css">
  <link rel="stylesheet" href="${ctx }/editor/theme/monokai.css">
  
  <style type="text/css">
	.CodeMirror {
		border-top: 1px solid #eee;
		border-bottom: 1px solid #eee;
		font-size: 18px;
		height: auto; 
	}
	.CodeMirror-scroll { max-height: 500px; min-height: 100px;}
  </style>
  <body class='main page'>
  <jsp:include page="/top.jsp"/>
  
  <div id='wrapper'>
      <section id='tools'>
        <ul class='breadcrumb' id='breadcrumb'>
          <li class='title'>任务</li>
          <li class='active'>编辑</li>
        </ul>
      </section><!-- Sidebar -->
  <jsp:include page="/sidebar.jsp"/>
    	
     <!-- Content -->
     <div id='content'>
     	<form id="job_form">
     		<input type="hidden" name="jobType" value="${_jobType }" >
     		<input type="hidden" name="_id" value="${obj._id }" >
             <fieldset>
               <legend>任务信息</legend>
               <div class='form-group row'>
	               <div class='col-lg-10'>
	                 <label class='control-label'>名称：</label>
	                 ${obj.name }
	               </div>
	                <div class='col-lg-2'>
	                   <label class='control-label'>状态</label>
	                   <c:if test="${obj.status==0}">停止</c:if>
                   	   <c:if test="${obj.status==1}">运行</c:if>
	                 </div>
               </div>
             </fieldset>
             
             
             <fieldset>
               <legend>参数配置</legend>
               <div class='form-group row'>
                 <c:if test="${_jobType=='http' }">
                 <div class='col-lg-3'>
                   <label class='control-label'>采集深度:</label>
                   ${obj.depth }
                 </div>
                 <div class='col-lg-3'>
                   <label class='control-label'>线程数:</label>
                   ${obj.threadNum }
                 </div>
                 <div class='col-lg-3'>
                   <label class='control-label'>采集方式:</label>
                   <c:if test="${obj.rule=='width'}">广度优先</c:if>
                   <c:if test="${obj.rule=='depth'}">深度优先</c:if>
                 </div>
                 <div class='col-lg-3'>
	               <label class='control-label'>保存html:</label>
	               <c:if test="${obj.saveHtml}">保存</c:if>
                   <c:if test="${!obj.saveHtml}">不保存</c:if>
	              </div>
	              
	              <div class='col-lg-3'>
	               <label class='control-label'>自动抽取url:</label>
	               <c:if test="${obj.parseUrl}">抽取</c:if>
                   <c:if test="${!obj.parseUrl}">不抽取</c:if>
	              </div>
	              
	              <div class='col-lg-3'>
	               <label class='control-label'>错误重试次数:</label>
                   ${obj.errCount }
	              </div>
	              
	               <div class='col-lg-3'>
	               	<label class='control-label'>超时时间:</label>
	               	${obj.timeout }
	               </div>
	              
	              <div class='col-lg-3'>
	               <label class='control-label'>是否使用代理:</label>
                   <c:if test="${proxy.saveHtml}">使用</c:if>
                   <c:if test="${!proxy.saveHtml}">不使用</c:if>
	              </div>
	              
	              <div class='col-lg-3'>
	               <label class='control-label'>抓取总数:</label>
                   ${totalNum }
	              </div>
	              
	              <div class='col-lg-3'>
	               <label class='control-label'>成功数:</label>
	               ${succNum }
	              </div>
	              <div class='col-lg-3'>
	               <label class='control-label'>失败数:</label>
	               ${errorNum } 
	              </div>
	              <div class='col-lg-3'>
	               <label class='control-label'>平均速率:</label>
	               ${speedPerMinute}(每分钟)
	              </div>
	              <div class='col-lg-3'>
	               <label class='control-label'>待爬任务数:</label>
	               ${taskCount}
	              </div>
	              <div class='col-lg-12'>
	                 <label class='control-label'>正则过滤:</label>
	                 <textarea class='form-control' rows='4' id="regexFilter" name="regexFilter" readonly="readonly">${obj.regexFilter }</textarea>
	               </div>
                </c:if>
                
                <c:if test="${_jobType=='data' }">
	                 <div class='col-lg-12'>
	                   <label class='control-label'>更新周期:</label>
	                   <input class='form-control' placeholder='单位毫秒 0 为一次性结束' type='text' name="sleepTime" value="${obj.sleepTime }">
                	</div>
               </c:if>
               </div>
             </fieldset>
             
             <fieldset>
               <legend>规则配置</legend>
               <div class='form-group'>
                  <label class='control-label'>输入</label>
                  <textarea class='form-control' rows='4'  id="input" name="input" readonly="readonly">${obj.input }</textarea>
               </div>
               
               <div class='form-group'>
                 <label class='control-label'>解析</label>
                 <table class="table table-bordered" id="doc_api_table" style="display: none">
	                  <thead>
					    <tr>
					      <th>名称</th>
					      <th>说明</th>
					      <th>例子</th>
					    </tr>
					  </thead>

	                  <tr class="success">
					    <td>内置对象</td>
					    <td><code>_doc</code>.(skipSave是否保存,<code>result</code>保存的结果,<code>document</code>网页解析对象Jsoup <code>html</code>:网页正文
					    <code>url</code>:当前网址<code>deep</code>:深度<code>fromUrl</code>:来源网址<code>)</td>
					    <td><code> _doc.skipSave = True ;</code></td>
					  </tr>
					  
					  <tr class="info">
					    <td rowspan="3" style="vertical-align:middle;">设置下一页</td>
					    <td><code>nextPage</code></td>
					    <td><code>_doc.nextPage="http://xxx/xxx.pageNo=3"</code></td>
					  </tr>
					   <tr class="info">
					    <td><code>void nextPage(String param, int step)</code></td>
					    <td><code>_doc.nextPage("pageNo", 1)</code></td>
					  </tr>
					  <tr class="info">
					    <td><code>void nextPageByTemplate(String template, int step)</code></td>
					    <td><code>_doc.nextPage("http://xxx{}xxx", 1)</code></td>
					  </tr>
					  
					  <tr class="success">
					    <td>抽取元素</td>
					    <td><code>void setValue(String key, String cssQuery, [String type :[string,int,double,data,float,long]])</code></td>
					    <td><code>_doc.setValue("title",".title")</code></td>
					  </tr>
					  
					  <tr class="info">
					    <td>抽取网址</td>
					    <td><code>void parseUrls( [String cssQuery])</code></td>
					    <td><code>_doc.parseUrls()</code></td>
					  </tr>
					  
					  <tr class="success">
					    <td>判断网址类型</td>
					    <td><code>boolean caseUrl(String regexId)</code></td>
					    <td><code>if _doc.caseUrl("xiangxi")</code></td>
					  </tr>
					  
				 </table>
                 <textarea class='form-control' rows='4' id="parse" id="parse" name="parse">${obj.parse==null?'#coding=utf-8':obj.parse }</textarea>
               </div>
               
               <div class='form-group'>
                 <label class='control-label'>输出</label>
                 <textarea class='form-control' rows='4' id="output" id="output" name="output">${obj.output }</textarea>
               </div>
             </fieldset>
             <!-- 
             <div class='form-actions text-right'>
               <button class='btn btn-success' type='button' id="reset_job">清空采集结果</button>
               <button class='btn btn-success' type='button' id="publish_job">提交</button>
               <button class='btn btn-info' type="button" id="test_job">测试</button>
             </div> -->
          </form>
          
          
         
     </div>
     
  </div>

  
	

<jsp:include page="/foot.jsp"/>
    
    
    <!--DEVEL-->
	<script src="${ctx }/editor/lib/codemirror.js"></script>
	<script src="${ctx }/editor/addon/dialog/dialog.js"></script>
	<script src="${ctx }/editor/addon/search/searchcursor.js"></script>
	<script src="${ctx }/editor/mode/clike/clike.js"></script>
	<script src="${ctx }/editor/addon/edit/matchbrackets.js"></script>
	<script src="${ctx }/editor/keymap/vim.js"></script>
	<script src="${ctx }/editor/addon/display/fullscreen.js"></script>
	<script src="${ctx }/editor/mode/python/python.js"></script>
	<script src="${ctx }/editor/mode/javascript/javascript.js"></script>
	
	<script src="${ctx }/js/beautify.js"></script>
	
	<script src="${ctx }/js/config_setting.js"></script>
	<!-- 任务Job JS配置 -->
	<script src="${ctx }/js/job/job_input_config.js"></script>
	<script src="${ctx }/js/job/job_output_config.js"></script>
	<script>
		var parse = CodeMirror.fromTextArea(document.getElementById("parse"), {
			lineNumbers : true,
			mode : "python",
			matchBrackets : true,
			theme : "monokai",
			readOnly: true,
		});

		
		var input = CodeMirror.fromTextArea(document.getElementById("input"), {
			lineNumbers : true,
			mode : "javascript",
			matchBrackets : true,
			theme : "monokai",
			readOnly: true,
		});
		
		var output = CodeMirror.fromTextArea(document.getElementById("output"), {
			lineNumbers : true,
			mode : "javascript",
			matchBrackets : true,
			theme : "monokai",
			readOnly: true,
		});
		
	</script>
  </body>
</html>
